﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;

public class SpawnManager : NetworkBehaviour {
    #region Instance
    public static SpawnManager instance = null;
    public GameObject Barrack;//兵营
    public GameObject Soldier;//步兵

    private GameObject tempObj;
    public void Awake()
    {
        instance = this;
    }
    #endregion
    [Command]
    public void CmdCreatbarr(Vector3 pos)
    {
        Barrack.transform.position = new Vector3(pos.x, 15.5f, pos.z);
        tempObj = Instantiate(Barrack, Barrack.transform.position, Barrack.transform.rotation) as GameObject;
        NetworkServer.Spawn(tempObj);
    }
    [Command]
    public void CmdCreatSoldier(Vector3 pos)
    {
        Soldier.transform.position = new Vector3(pos.x, 15.5f, pos.z);
        tempObj = Instantiate(Soldier, Soldier.transform.position, Soldier.transform.rotation) as GameObject;
        NetworkServer.Spawn(tempObj);
    }
    [Command]
    public void CmdBomb(Vector3 mousePos)
    {
        GameObject bomb = Resources.Load("Prefabs/Bomb") as GameObject;
        GameObject tempbomb = Instantiate(bomb, mousePos, bomb.transform.rotation) as GameObject;
        NetworkServer.Spawn(tempbomb);
        GameObject.Destroy(tempbomb, 5.0f);
    }
}
